package com.yewen.http.service;


import com.yewen.http.entity.Account;
import com.yewen.http.entity.EducationCounselor;
import com.yewen.http.entity.LoginAccount;
import com.yewen.http.repository.AccountRepository;
import com.yewen.http.repository.EducationCounselorRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AccountService {
    @Autowired
    private AccountRepository accountRepository;
    @Autowired
    private EducationCounselorRepository educationCounselorRepository;

    public boolean loginAuth(LoginAccount loginAccount){
        return accountRepository.loginAuth(loginAccount)||
                educationCounselorRepository.loginAuth(loginAccount);
    }
    public boolean save(Account account){
        if (account==null)return false;
        accountRepository.save(account);
        return true;
    }
    public Account findAccountById(String id){
        return accountRepository.findAccountById(id);
    }
    public Account findAccountByTel(String tel){
        return accountRepository.findAccountByTel(tel);
    }
    public Account findAccountByEmail(String email){
        return accountRepository.findAccountByEmail(email);
    }
}
